// index_pkg/pages/defer/index.js
import Toast from '@vant/weapp/toast/toast';
Page({

  /**
   * 页面的初始数据
   */
  data: {
    delay:'',
    hShow:false,
    currentDate: '12:00',
    minHour:14,
    maxHour:15,
    charCount: 0,
    value:'',
    maxLimit:50
  },
  handleInput(event) {
    console.log(event);
    const value = event.detail.value;
    // const count = value.replace(/\s+/g, ' ').trim().length;
    const count = event.detail.cursor;
    if(count>this.data.maxLimit){
      this.setData({
        charCount:50
      });
    }else {
      this.setData({
        charCount: count,
        value
      });
    }
    // this.setData({
    //   charCount: count,
    //   value
    // });
  },
  isShow(){
    this.setData({hShow:!this.data.hShow})
  },
  
  openDateLayer(){
    this.setData({hShow: true,})
 },
 onInput(e) {
   console.log(e);
   this.setData({
     delay:'2022.05.04'+'  '+ e.detail,
     hShow: false,
   });
 },
 closeDateLayer() { this.setData({ hShow: false }) },
 async delivery(e){
   console.log(e);
   await wx.$toast('提交成功')
   wx.navigateBack({ delta: 1})
  //  Toast({
  //    message: '提交成功',
  //    position:'bottom',
  //    onClose: () => {
  //     wx.navigateBack({ delta: 1})
  //   //  console.log('执行OnClose函数');
  //    }
  //  })
  //  wx.navigateBack({ delta: 1})
 },
 closeDateLayer() {
  this.setData({ hShow: false })
},

})